package com.seed.core.column;

import com.seed.core.enumeration.SqlOp;
import com.seed.core.pojo.seed.Property;
import org.apache.ibatis.type.TypeHandler;

public abstract class Column implements Property {
    protected String name;
    protected Integer length; // 数据库中的字段长度，比如 varchar(32) 中的 32
    protected Boolean required;
    protected Boolean unique;
    protected String label;
    protected String comment; // 字段注释
    protected String onInsertValue; // 插入数据时列的默认值，参与sql的拼接
    protected String onUpdateValue; // 更新数据时列的默认值，参与sql的拼接
    protected Class<? extends TypeHandler<?>> typeHandler; // 列的类型处理器
//    private String defVal; //COLUMN_DEF 默认值
//
//    private Integer precision;
//    private Integer scale;
//    private Object min;
//    private Object max;
//    private String rel;
//    private Map<String, String> options;

    public boolean isLarge() {
        return false;
    }
    public abstract SqlOp getDefaultOp();

    public abstract Column copy();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    public Boolean getRequired() {
        return required;
    }

    public void setRequired(Boolean required) {
        this.required = required;
    }

    public Boolean getUnique() {
        return unique;
    }

    public void setUnique(Boolean unique) {
        this.unique = unique;
    }

    @Override
    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    @Override
    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getOnInsertValue() {
        return onInsertValue;
    }

    public void setOnInsertValue(String onInsertValue) {
        this.onInsertValue = onInsertValue;
    }

    public String getOnUpdateValue() {
        return onUpdateValue;
    }

    public void setOnUpdateValue(String onUpdateValue) {
        this.onUpdateValue = onUpdateValue;
    }

    public Class<? extends TypeHandler<?>> getTypeHandler() {
        return typeHandler;
    }

    public void setTypeHandler(Class<? extends TypeHandler<?>> typeHandler) {
        this.typeHandler = typeHandler;
    }
}
